package hashfunctions;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class HashSHA1_128 extends HashFunction_128 {

	  public String hash(String clearTextPassword)
      throws NoSuchAlgorithmException
	{
	MessageDigest md = MessageDigest.getInstance("SHA-1");
	
	md.update(clearTextPassword.getBytes());
	
	byte[] sss=md.digest();
	char[] aaa=new char[md.getDigestLength()];
	for(int i=0; i<aaa.length;i++){
		if (sss[i]==0)
			sss[i]=(byte) 128;
		aaa[i]=(char)sss[i];	
	}
	
	return new String(aaa).substring(0, 16);
	}
	  
	  public String tipo() {
			return "SHA1";
		}

}
